<template>
	<view class="page__content">

		<view class="page__content__main">
			<u-empty mode="history" icon="/static/Image/Img/history.png" iconSize="160" text="请手动配对设备">
				<template>
					<button type="primary" class="content_bottom_primary_Btn" @click="openBluetoothSetting">
						<text>点击前往配对</text>
					</button>
				</template>
			</u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
			}
		},
		methods: {

			openBluetoothSetting() {
				const system = uni.getSystemInfoSync().platform
				if (system === 'android') {
					try {
						var main = plus.android.runtimeMainActivity();
						var Intent = plus.android.importClass('android.content.Intent');
						var Settings = plus.android.importClass('android.provider.Settings');
						var intent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS);
						main.startActivity(intent);
					} catch (e) {
						console.error('跳转失败', e);
						uni.showToast({
							title: '无法打开蓝牙设置',
							icon: 'none'
						});
					}
				} else if (system === 'ios') {
					plus.runtime.openURL('App-Prefs:root=Bluetooth');
				} else {
					uni.showToast({
						title: '当前平台不支持跳转',
						icon: 'none'
					});
				}
			}

		}
	}
</script>

<style lang="scss">
	.page__content {
		height: 100%;

		&__main {
			.content_bottom_primary_Btn {
				font-size: 14px;
				margin-top: 15px;
				padding: 4px 15px;
			}
		}
	}
</style>